import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
 * 针对 {@link Calculator} 的单元测试。
 */
public class CalculatorTest {

    /**
     * 测试加法逻辑。
     */
    @Test
    public void testAdd() {
        Calculator calculator = new Calculator();
        Assertions.assertEquals(6, calculator.add(2, 3));
        Assertions.assertEquals(0, calculator.add(-2, 2));
        System.out.println("-----");
        System.out.println("-----");
    }

    /**
     * 测试减法逻辑。
     */
    @Test
    public void testSubtract() {
        Calculator calculator = new Calculator();
        Assertions.assertEquals(1, calculator.subtract(3, 2));
        Assertions.assertEquals(-4, calculator.subtract(-2, 2));
    }

    /**
     * 测试乘法逻辑。
     */
    @Test
    public void testMultiply() {
        Calculator calculator = new Calculator();
        Assertions.assertEquals(6, calculator.multiply(2, 3));
        Assertions.assertEquals(-4, calculator.multiply(-2, 2));
    }

    /**
     * 测试除法逻辑及异常分支。
     */
    @Test
    public void testDivide() {
        Calculator calculator = new Calculator();
        Assertions.assertEquals(2, calculator.divide(5, 2)); // 整数除法 5/2=2
    }

    /**
     * 测试除以 0 抛出异常。
     */
    @Test
    public void testDivideByZero() {
        Calculator calculator = new Calculator();
        Assertions.assertThrows(IllegalArgumentException.class, () -> calculator.divide(1, 0));
    }
}


